//
//  AboutUSViewController.m
//  CBT
//
//  Created by Mr.Zhang on 2019/3/1.
//  Copyright © 2019 Mr.Zhang. All rights reserved.
//

#import "AboutUSViewController.h"
#import "SettingPaymentPwdViewController.h"
#import "LoginPwdChangeViewController.h"
#import "ChangePaymentPwdViewController.h"
#import "ContactUSViewController.h"

#import "SettingPwdCell.h"

@interface AboutUSViewController ()<UITableViewDelegate,UITableViewDataSource,UITextViewDelegate>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *dataArray;

@end

@implementation AboutUSViewController

#pragma mark - VC Life

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.dataArray = @[kLocalizedString(@"意见反馈", nil),kLocalizedString(@"联系我们", nil)];
    
    [self.view addSubview:self.tableView];
    
    self.navigationItem.title = kLocalizedString(@"关于我们", nil);
}

#pragma mark - ChangeLanguageNotification

- (void)changeLanguage
{
    self.navigationItem.title = kLocalizedString(@"关于我们", nil);
    [self.tableView reloadData];
}

#pragma mark - UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SettingPwdCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    cell.backgroundColor = UIColorFromRGB(0xF7F7F7);
    cell.indexRow = indexPath.row;
    cell.titleText = self.dataArray[indexPath.row];
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
        LoginPwdChangeViewController *aboutus = [story instantiateViewControllerWithIdentifier:@"FeedbackID"];
        [self.navigationController pushViewController:aboutus animated:YES];
    }else{
        UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
        ContactUSViewController *aboutus = [story instantiateViewControllerWithIdentifier:@"ContactUSID"];
        [self.navigationController pushViewController:aboutus animated:YES];
    }
}

#pragma mark - Lazy

- (UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, ScreenNarrowSide, ScreenWideSide - self.tabBarController.tabBar.bounds.size.height - 15) style:(UITableViewStylePlain)];
        _tableView.backgroundColor = [UIColor clearColor];
        //        _tableView.contentInset = UIEdgeInsetsMake(5, 0, 0, 0);
        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.separatorStyle = UITableViewCellEditingStyleNone;
        
        _tableView.delegate = self;
        _tableView.dataSource = self;
        
        if (@available(iOS 11.0, *)){
            _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        }else{
            self.automaticallyAdjustsScrollViewInsets = NO;
        }
        _tableView.estimatedRowHeight           = 0;
        _tableView.estimatedSectionHeaderHeight = 0;
        _tableView.estimatedSectionFooterHeight = 0;
        
        [_tableView registerClass:[SettingPwdCell class] forCellReuseIdentifier:@"Cell"];
        
        _tableView.tableFooterView = [UIView new];
    }
    return _tableView;
}

@end
